<?php

namespace App\Models;

class Inspection extends Model
{
    protected $fillable = [
        'inspection_user_name',
        'inspection_user_phone',
        'inspection_type',
        'inspection_content',
        'inspection_img',
        'housings_id',
    ];
    protected $table = 'inspection';
    protected $InspectionType =[1=>'违搭违建问题',2=>'消防安全问题',3=>'违规食品经营问题',4=>'燃气安全问题',5=>'电力安全问题',6=>'实名登记问题',7=>'未成年人登记问题',8=>'卫生问题',9=>'其他'];
    protected $InspectionStatus =[1=>'已整改',2=>'待整改',3=>'已办结',4=>'未通过'];
    public function getInspectionTypeAttribute($value)
    {
        return isset($this->InspectionType[$value]) ? $this->InspectionType[$value] : reset($this->InspectionType);
    }
    public function getInspectionStatusAttribute($value)
    {
        return isset($this->InspectionStatus[$value]) ? $this->InspectionStatus[$value] : reset($this->InspectionStatus);
    }
    public function housings()
    {
        return $this->hasOne(Housings::class,'housings_num','housings_id')->select('id','housings_num','hou_address');;
    }

}
